package cn.itcast.domain;

import org.junit.Test;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;


public class Lx01 {

    @Test
    public void 查询() throws Exception {
        Class.forName("com.mysql.jdbc.Driver");

        Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/moneydb", "root", "root");

        Statement statement = connection.createStatement();

        ResultSet resultSet = statement.executeQuery("SELECT id'编号',NAME '姓名',money '余额' FROM account");

        while (resultSet.next()) {
            Object id = resultSet.getObject("编号");
            Object name = resultSet.getObject("姓名");
            Object money = resultSet.getObject("余额");

            System.out.println("编号" + id + ",姓名" + name + ",余额" + money);

        }
        resultSet.close();
        statement.close();
    }


    class lx02 {
        @Test
        public void 查询() throws Exception {
            Class.forName("com.mysql.jdbc.Driver");

            Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/moneydb", "root", "root");

            Statement statement = connection.createStatement();

            ResultSet resultSet = statement.executeQuery("SELECT  id'编号',NAME '姓名',money'余额' FROM account");

            while (resultSet.next()) {
                Object id = resultSet.getObject("编号");
                Object name = resultSet.getObject("姓名");
                Object money = resultSet.getObject("余额");

                System.out.println("编号" + id + ",姓名" + name + ",余额" + money);
            }
            resultSet.close();
            statement.close();
        }
    }
}

class lx03{
    @Test
    public void 查询() throws Exception{
        Class.forName("com.mysql.jdbc.Driver");
        Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/moneydb", "root", "root");
        Statement statement = connection.createStatement();
        ResultSet resultSet = statement.executeQuery("SELECT  id'',NAME '',money'' FROM account");
        while (resultSet.next()){
            Object id = resultSet.getObject("编号");
            Object name = resultSet.getObject("姓名");
            Object money = resultSet.getObject("余额");
            System.out.println("编号"+id+",姓名"+name+",余额"+money);
        }
        resultSet.close();
        statement.close();
    }
}

class lx04{
    @Test
    public void 查询() throws Exception{
        Class.forName("com.mysql.jdbc.Driver");
        Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/moneydb","root","root");
        Statement statement = connection.createStatement();
        ResultSet resultSet = statement.executeQuery("SELECT id'',NAME '',money'' FROM accpint");
        while (resultSet.next()){
            Object id = resultSet.getObject("编号");
            Object name = resultSet.getObject("姓名");
            Object money = resultSet.getObject("余额");
            System.out.println(""+id+","+name+","+money);
        }
        resultSet.close();
        statement.close();
    }
}

class lx05{
    @Test
    private void 查询() throws Exception{
        Class.forName("com.mysql.jdbc.Driver");
        Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/moneydb", "root", "toot");
        Statement statement = connection.createStatement();
        ResultSet resultSet = statement.executeQuery("SELECT id'编号',name'姓名',money'余额'");
        while (resultSet.next()){
            Object id = resultSet.getObject("编号");
            Object name = resultSet.getObject("姓名");
            Object money = resultSet.getObject("余额");
            System.out.println("编号"+id+",姓名"+name+",余额"+money);
        }
        resultSet.close();
        statement.close();
    }
}

class lx06{
    @Test
    public void 查询() throws Exception{
        Class.forName("com.mysql.jdbc.Driver");
        DriverManager.getConnection("jdbc.c ")
    }
}